package star.cloud.asme.system.department;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Transient;
import lombok.*;
import org.springframework.cache.annotation.EnableCaching;
import star.cloud.asme.base.mybatis.IBaseEntity;
import star.cloud.asme.system.user.User;

import java.util.Collection;

@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor(force = true)
@AllArgsConstructor
@Entity(name = "senpec_system_department")
@TableName("senpec_system_department")
@EnableCaching
public class Department extends IBaseEntity<Department> {
    //组织层级（公司、部门、处室）
    private String level;

    @Column(length = 30, nullable = false)
    private String label;
    //代号
    private String reference;

    private Long pid;
    // 本级组织负责人
    private String managerUsername;
    @Transient
    @TableField(exist = false)
    private User manager;
    // 分管领导
    private String deputyManagerUsername;
    @Transient
    @TableField(exist = false)
    private User deputyManager;
    //是否为根节点
    @Transient
    @TableField(exist = false)
    @Builder.Default
    private Boolean isRoot = false;
    //是否为叶子节点
    @Transient
    @TableField(exist = false)
    private Boolean isLeaf;
    @Transient
    @TableField(exist = false)
    private Collection<Department> children;
    @Transient
    @TableField(exist = false)
    private Department parent;
    @Transient
    @TableField(exist = false)
    @Builder.Default
    private Long peopleQuantity = 0L;
    @Transient
    @TableField(exist = false)
    @Builder.Default
    private Long peopleQuantityInCurrent = 0L;

}